
from app.db.models.packages import Packages
from app.db.models.balances import Balances
from app.handler.v2_users import calculate_feature


def update_balance_feature():
    pids = Packages.objects.filter(feature__vulManualTask=True).distinct("id")
    uids = Balances.objects.filter(planId__in=pids, feature__vulManualTask=False).distinct("uid")
    print(f"user id: {uids}")
    for uid in uids:
        feature = calculate_feature(uid)
        balance = Balances.objects.filter(uid=uid).first()
        balance.update(feature=feature)


